﻿@page
@model UploadModel
@{
    ViewData["Title"] = "上传照片";
}

<div class="container mt-5">
    <div class="row justify-content-center">
        <div class="col-md-6">
            <div class="card">
                <div class="card-header">
                    <h2>上传儿童照片</h2>
                </div>
                <div class="card-body">
                    <!-- 上传表单 -->
                    <form method="post" enctype="multipart/form-data">
                        <!-- 图片文件 -->
                        <div class="mb-3">
                            <label for="Upload_File" class="form-label">@Html.DisplayNameFor(m => m.Upload.File)</label>
                            <input type="file" class="form-control" id="Upload_File"
                                   name="Upload.File" accept="image/*" required>
                            <div class="form-text">支持JPG、PNG、GIF、WebP格式，最大5MB</div>
                        </div>

                        <!-- 照片描述 -->
                        <div class="mb-3">
                            <label for="Upload_Description" class="form-label">@Html.DisplayNameFor(m => m.Upload.Description)</label>
                            <textarea class="form-control" id="Upload_Description"
                                      name="Upload.Description" rows="3"
                                      placeholder="例如：宝宝第一次去公园"></textarea>
                        </div>

                        <!-- 照片分类（下拉框） -->
                        <div class="mb-3">
                            <label asp-for="Upload.Category" class="form-label"></label>
                            <select class="form-control" asp-for="Upload.Category"
                                    asp-items="Model.Upload.CategoryOptions" required>
                                <option value="">请选择分类</option>
                            </select>
                            <span asp-validation-for="Upload.Category" class="text-danger"></span>
                        </div>

                        <!-- 错误提示 -->
                        @if (!ModelState.IsValid)
                        {
                            <div class="alert alert-danger">
                                @foreach (var error in ModelState.Values.SelectMany(v => v.Errors))
                                {
                                    <div>@error.ErrorMessage</div>
                                }
                            </div>
                        }

                        <!-- 按钮 -->
                        <div class="d-flex justify-content-between">
                            <a asp-page="Index" class="btn btn-outline-secondary">返回列表</a>
                            <button type="submit" class="btn btn-primary">确认上传</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>